jQuery.loadscore = function(_videoid) {
	var name = $.checkcookie("name");
	$.ajax({
		type : "GET",
		url : "/musicai/score/query",
		global : false,
		beforeSend : function(req) {
			req.setRequestHeader("Accept", "application/application+xml");
		},
		data : {
			videoid : _videoid,
			user : name
		}
	}).done(function(xml) {
		var score_like = $(xml).find("score_like").text();
		$("#score-up").html(score_like + "人顶");
		
		var score_unlike = $(xml).find("score_unlike").text();
		$("#score-down").html(score_unlike + "人顶");
		
	});
};

jQuery.addscoreevent = function() {
	$("#do-score-up").click(function() {
		var _videoid = $(".playing").attr("id");
		if($(this).hasClass("score-button")==true){
			$(this).removeClass("score-button");
			$(this).addClass("pressed-score-button");
			var name = $.checkcookie("name");
			if(name!=""){
				if($("#scoreupdatediv").length == 0){
					$("#score-bar").append("<div id=\"scoreupdatediv\">正在提交您的评分...</div>");
				}else{
					$("#scoreupdatediv").html("正在提交您的评分...");
				}
				$.ajax({
					type : "GET",
					url : "/musicai/score/update_like",
					global : false,
					beforeSend : function(req) {
						req.setRequestHeader("Accept", "application/application+xml");
					},
					data : {
						videoid : _videoid,
						user : name
					}
				}).done(function(xml) {
//					var score = $(xml).find("score").text();
//					$("#score-up").html(score + "人顶");
					$("#scoreupdatediv").html("评分已提交，谢谢参与。");
				});
			}else{
				$("#score-bar").append("<div id=\"scoreupdatediv\">请先登录...</div>");
				
			}
		
		}else{
			$(this).removeClass("pressed-score-button");
			$(this).addClass("score-button");
			$("#scoreupdatediv").remove();
			
		}
	});
	
	$("#do-score-down").click(function() {
		var _videoid = $(".playing").attr("id");
		if($(this).hasClass("score-button")==true){
			$(this).removeClass("score-button");
			$(this).addClass("pressed-score-button");
			var name = $.checkcookie("name");
			if(name!=""){
				if($("#scoreupdatediv").length == 0){
					$("#score-bar").append("<div id=\"scoreupdatediv\">正在提交您的评分...</div>");
				}else{
					$("#scoreupdatediv").html("正在提交您的评分...");
				}
				$.ajax({
					type : "GET",
					url : "/musicai/score/update_unlike",
					global : false,
					beforeSend : function(req) {
						req.setRequestHeader("Accept", "application/application+xml");
					},
					data : {
						videoid : _videoid,
						user : name
					}
				}).done(function(xml) {
					$("#scoreupdatediv").html("评分已提交，谢谢参与。");
				});
			}else{
				$("#score-bar").append("<div id=\"scoreupdatediv\">请先登录...</div>");
				
			}
		
		}else{
			$(this).removeClass("pressed-score-button");
			$(this).addClass("score-button");
			$("#scoreupdatediv").remove();
			
		}
	});
	

}